<?php
/**
 * IfElse
 *
 * The 'if' construct is one of the most important features of many languages,
 * GOP included. It allows for conditional execution of code fragments.
 *
 * Often you'd want to execute a statement if a certain condition is met,
 * and a different statement if the condition is not met. This is what
 * else is for. 'else' extends an 'if' statement to execute a statement in
 * case the expression in the 'if' statement evaluates to FALSE.
 *
 * @author  Badrus Said <badrus.said@gmail.com>
 * @since   gop1.0
 */
final class gop_IfElse extends gop_Base {
    public function execute(gop_Base $_caller = null) {
        if ($this->getReturn()) return;
        $this->getContext()->getCallee($this->expression)->execute($this);
        if ($this->getResult()) {
        if (isset($this->ifTrue)) {
            if ($this->getContext()->hasCallee($this->ifTrue)) $this->getContext()->getCallee($this->ifTrue)->execute($this);
        }} else {
        if (isset($this->ifFalse)) {
            if ($this->getContext()->hasCallee($this->ifFalse)) $this->getContext()->getCallee($this->ifFalse)->execute($this);
        }}
        $this->setCaller($_caller);
        $this->setResult($this->getResult());
        $this->chainExec();
    }
}
?>